﻿#include "sprite.h"

Sprite::Sprite(QWidget *parent,QString x) :
    QPushButton(parent)
{
    pixmap=new QPixmap;
    this->pixmap->load(x);
    this->widget=new QWidget(this);
    widget->setFixedSize(200,200);
    widget->setStyleSheet("background-color: rgba(211,211,211, 0.3);");
    widget->hide();
    closeButton=new QPushButton(widget);
}

Sprite::~Sprite()
{
}

void Sprite::paintEvent(QPaintEvent *)
{
    QPainter painter(this);

    // 将图片设置到 QPushButton 中
    painter.drawPixmap(rect(), *pixmap);

    if(this->isMarked)
        this->show();
    else
        this->hide();
}

